/*
* Copyright 2009 NOR_/D Labs <http://labs.nortd.com>
*
* This file is part of SceneExpression.
* SceneExpression is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License 
* as published by the Free Software Foundation, either version 3 of 
* the License, or (at your option) any later version. For details
* see <http://www.gnu.org/licenses/>.
*
* * *
* 
*/

#ifndef SX_TEXTBOX
#define SX_TEXTBOX


#include <osgText/Text>
#include "sxShape.h"



class sxTextShape:  public sxShape2D {
    public:
    
        enum  Layout { LEFT_TO_RIGHT, RIGHT_TO_LEFT, VERTICAL };
  
        sxTextShape();
        
        void setText( std::string text );
        std::string getText();
        
        void setCharacterSize( float size );
        float getCharacterSize();
        
        void setColor( float r, float g, float b, float a );
        void setBackgroundColor( osg::Vec4 color );
        void setBackgroundColor( float r, float g, float b, float a=1.0f );
        osg::Vec4 getBackgroundColor();
                
        void setPadding( float padding );
        float getPaddingLeft() {return _paddingLeft;}
        float getPaddingRight() {return _paddingRight;}
        float getPaddingTop() {return _paddingTop;}
        float getPaddingBottom() {return _paddingBottom;}
        
        void setLayout( Layout layout );
        
        virtual void setShape( float width, float height);
        virtual float getWidth();
        virtual float getHeight();        
                
        virtual void reshape();        
        
            
    protected:
        std::string _defaultTypeface;  
        osg::ref_ptr<osgText::Text>   _text;
        float _width, _height;  
        
        float _characterSize;
        float _paddingLeft, _paddingRight, _paddingTop, _paddingBottom;
    
        void addRoundedRect( float x, float y, float w, float h, float r, osg::Vec3Array* vertices );
        void roundedCorner( float x, float y, float pivotX, float pivotY, osg::Vec3Array* vertices );    
};



#endif